{
    "version": "1.3.2",
    "name": "org.apache.cordova.file",
    "cordova_name": "File",
    "description": "Cordova File Plugin",
    "license": "Apache 2.0",
    "repo": "https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git",
    "issue": "https://issues.apache.org/jira/browse/CB/component/12320651",
    "keywords": [
        "cordova",
        "file"
    ],
    "platforms": [
        "android",
        "amazon-fireos",
        "ubuntu",
        "ios",
        "wp7",
        "wp8",
        "blackberry10",
        "windows8",
        "windows",
        "firefoxos"
    ],
    "engines": [],
    "englishdoc": "<!---\n    Licensed to the Apache Software Foundation (ASF) under one\n    or more contributor license agreements.  See the NOTICE file\n    distributed with this work for additional information\n    regarding copyright ownership.  The ASF licenses this file\n    to you under the Apache License, Version 2.0 (the\n    \"License\"); you may not use this file except in compliance\n    with the License.  You may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing,\n    software distributed under the License is distributed on an\n    \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n    KIND, either express or implied.  See the License for the\n    specific language governing permissions and limitations\n    under the License.\n-->\n\n# org.apache.cordova.file\n\n\nThis plugin implements a File API allowing read/write access to files residing on the device.\n\nThis plugin is based on several specs, including : \nThe HTML5 File API\n[http://www.w3.org/TR/FileAPI/](http://www.w3.org/TR/FileAPI/)\n\nThe (now-defunct) Directories and System extensions\nLatest: \n[http://www.w3.org/TR/2012/WD-file-system-api-20120417/](http://www.w3.org/TR/2012/WD-file-system-api-20120417/)\nAlthough most of the plugin code was written when an earlier spec was current:\n[http://www.w3.org/TR/2011/WD-file-system-api-20110419/](http://www.w3.org/TR/2011/WD-file-system-api-20110419/)\n\nIt also implements the FileWriter spec :\n[http://dev.w3.org/2009/dap/file-system/file-writer.html](http://dev.w3.org/2009/dap/file-system/file-writer.html)\n\nFor usage, please refer to HTML5 Rocks' excellent [FileSystem article.](http://www.html5rocks.com/en/tutorials/file/filesystem/)\n\nFor an overview of other storage options, refer to Cordova's\n[storage guide](http://cordova.apache.org/docs/en/edge/cordova_storage_storage.md.html).\n\nThis plugin defines global `cordova.file` object.\n\nAlthough in the global scope, it is not available until after the `deviceready` event.\n\n    document.addEventListener(\"deviceready\", onDeviceReady, false);\n    function onDeviceReady() {\n        console.log(cordova.file);\n    }\n\n## Installation\n\n    cordova plugin add org.apache.cordova.file\n\n## Supported Platforms\n\n- Amazon Fire OS\n- Android\n- BlackBerry 10\n- Firefox OS\n- iOS\n- Windows Phone 7 and 8*\n- Windows 8*\n\n\\* _These platforms do not support `FileReader.readAsArrayBuffer` nor `FileWriter.write(blob)`._\n\n## Where to Store Files\n\nAs of v1.2.0, URLs to important file-system directories are provided.\nEach URL is in the form _file:///path/to/spot/_, and can be converted to a\n`DirectoryEntry` using `window.resolveLocalFileSystemURL()`.\n\n* `cordova.file.applicationDirectory` - Read-only directory where the application \n  is installed. (_iOS_, _Android_, _BlackBerry 10_)\n\n* `cordova.file.applicationStorageDirectory` - Root directory of the application's \n  sandbox; on iOS this location is read-only (but specific subdirectories [like \n  `/Documents`] are read-write). All data contained within is private to the app. (\n  _iOS_, _Android_, _BlackBerry 10_)\n\n* `cordova.file.dataDirectory` - Persistent and private data storage within the \n  application's sandbox using internal memory (on Android, if you need to use \n  external memory, use `.externalDataDirectory`). On iOS, this directory is not \n  synced with iCloud (use `.syncedDataDirectory`). (_iOS_, _Android_, _BlackBerry 10_)\n\n* `cordova.file.cacheDirectory` -  Directory for cached data files or any files \n  that your app can re-create easily. The OS may delete these files when the device \n  runs low on storage, nevertheless, apps should not rely on the OS to delete files \n  in here. (_iOS_, _Android_, _BlackBerry 10_)\n\n* `cordova.file.externalApplicationStorageDirectory` - Application space on \n  external storage. (_Android_)\n\n* `cordova.file.externalDataDirectory` - Where to put app-specific data files on \n  external storage. (_Android_)\n\n* `cordova.file.externalCacheDirectory` - Application cache on external storage. \n  (_Android_)\n\n* `cordova.file.externalRootDirectory` - External storage (SD card) root. (_Android_, _BlackBerry 10_)\n\n* `cordova.file.tempDirectory` - Temp directory that the OS can clear at will. Do not \n  rely on the OS to clear this directory; your app should always remove files as \n  applicable. (_iOS_)\n\n* `cordova.file.syncedDataDirectory` - Holds app-specific files that should be synced \n  (e.g. to iCloud). (_iOS_)\n\n* `cordova.file.documentsDirectory` - Files private to the app, but that are meaningful \n  to other application (e.g. Office files). (_iOS_)\n\n* `cordova.file.sharedDirectory` - Files globally available to all applications (_BlackBerry 10_)\n\n## File System Layouts\n\nAlthough technically an implementation detail, it can be very useful to know how \nthe `cordova.file.*` properties map to physical paths on a real device.\n\n### iOS File System Layout\n\n| Device Path                                    | `cordova.file.*`            | `iosExtraFileSystems` | r/w? | persistent? | OS clears | sync | private |\n|:-----------------------------------------------|:----------------------------|:----------------------|:----:|:-----------:|:---------:|:----:|:-------:|\n| `/var/mobile/Applications/<UUID>/`             | applicationStorageDirectory | -                     | r    |     N/A     |     N/A   | N/A  |   Yes   |\n| &nbsp;&nbsp;&nbsp;`appname.app/`               | applicationDirectory        | bundle                | r    |     N/A     |     N/A   | N/A  |   Yes   |\n| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`www/`     | -                           | -                     | r    |     N/A     |     N/A   | N/A  |   Yes   |\n| &nbsp;&nbsp;&nbsp;`Documents/`                 | documentsDirectory          | documents             | r/w  |     Yes     |     No    | Yes  |   Yes   |\n| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`NoCloud/` | -                           | documents-nosync      | r/w  |     Yes     |     No    | No   |   Yes   |\n| &nbsp;&nbsp;&nbsp;`Library`                    | -                           | library               | r/w  |     Yes     |     No    | Yes? |   Yes   |\n| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`NoCloud/` | dataDirectory               | library-nosync        | r/w  |     Yes     |     No    | No   |   Yes   |\n| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`Cloud/`   | syncedDataDirectory         | -                     | r/w  |     Yes     |     No    | Yes  |   Yes   |\n| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`Caches/`  | cacheDirectory              | cache                 | r/w  |     Yes*    |  Yes\\*\\*\\*| No   |   Yes   |\n| &nbsp;&nbsp;&nbsp;`tmp/`                       | tempDirectory               | -                     | r/w  |     No\\*\\*  |  Yes\\*\\*\\*| No   |   Yes   |\n\n\n  \\* Files persist across app restarts and upgrades, but this directory can \n     be cleared whenever the OS desires. Your app should be able to recreate any \n     content that might be deleted.\n\n\\*\\* Files may persist across app restarts, but do not rely on this behavior. Files \n     are not guaranteed to persist across updates. Your app should remove files from \n     this directory when it is applicable, as the OS does not guarantee when (or even \n     if) these files are removed.\n\n\\*\\*\\* The OS may clear the contents of this directory whenever it feels it is \n     necessary, but do not rely on this. You should clear this directory as \n     appropriate for your application.\n\n### Android File System Layout\n\n| Device Path                                     | `cordova.file.*`            | `AndroidExtraFileSystems` | r/w? | persistent? | OS clears | private |\n|:------------------------------------------------|:----------------------------|:--------------------------|:----:|:-----------:|:---------:|:-------:|\n| `file:///android_asset/`                        | applicationDirectory        |                           | r    |     N/A     |     N/A   |   Yes   |\n| `/data/data/<app-id>/`                          | applicationStorageDirectory | -                         | r/w  |     N/A     |     N/A   |   Yes   |\n| &nbsp;&nbsp;&nbsp;`cache`                       | cacheDirectory              | cache                     | r/w  |     Yes     |     Yes\\* |   Yes   |\n| &nbsp;&nbsp;&nbsp;`files`                       | dataDirectory               | files                     | r/w  |     Yes     |     No    |   Yes   |\n| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`Documents` |                             | documents                 | r/w  |     Yes     |     No    |   Yes   |\n| `<sdcard>/`                                     | externalRootDirectory       | sdcard                    | r/w  |     Yes     |     No    |   No    |\n| &nbsp;&nbsp;&nbsp;`Android/data/<app-id>/`      | externalApplicationStorageDirectory | -                 | r/w  |     Yes     |     No    |   No    |\n| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`cache`     | externalCacheDirectry       | cache-external            | r/w  |     Yes     |     No\\*\\*|   No    |\n| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`files`     | externalDataDirectory       | files-external            | r/w  |     Yes     |     No    |   No    |\n\n\\* The OS may periodically clear this directory, but do not rely on this behavior. Clear \n   the contents of this directory as appropriate for your application. Should a user \n   purge the cache manually, the contents of this directory are removed.\n\n\\*\\* The OS does not clear this directory automatically; you are responsible for managing \n     the contents yourself. Should the user purge the cache manually, the contents of the \n     directory are removed.\n\n**Note**: If external storage can't be mounted, the `cordova.file.external*` \nproperties are `null`.\n\n### BlackBerry 10 File System Layout\n\n| Device Path                                                  | `cordova.file.*`            | r/w? | persistent? | OS clears | private |\n|:-------------------------------------------------------------|:----------------------------|:----:|:-----------:|:---------:|:-------:|\n| `file:///accounts/1000/appdata/<app id>/`                    | applicationStorageDirectory | r    |     N/A     |     N/A   |   Yes   |\n| &nbsp;&nbsp;&nbsp;`app/native`                               | applicationDirectory        | r    |     N/A     |     N/A   |   Yes   |\n| &nbsp;&nbsp;&nbsp;`data/webviews/webfs/temporary/local__0`   | cacheDirectory              | r/w  |     No      |     Yes   |   Yes   |\n| &nbsp;&nbsp;&nbsp;`data/webviews/webfs/persistent/local__0`  | dataDirectory               | r/w  |     Yes     |     No    |   Yes   |\n| `file:///accounts/1000/removable/sdcard`                     | externalRemovableDirectory  | r/w  |     Yes     |     No    |   No    |\n| `file:///accounts/1000/shared`                               | sharedDirectory             | r/w  |     Yes     |     No    |   No    |\n\n*Note*: When application is deployed to work perimeter, all paths are relative to /accounts/1000-enterprise.\n\n## Android Quirks\n\n### Android Persistent storage location\n\nThere are multiple valid locations to store persistent files on an Android\ndevice. See [this page](http://developer.android.com/guide/topics/data/data-storage.html)\nfor an extensive discussion of the various possibilities.\n\nPrevious versions of the plugin would choose the location of the temporary and\npersistent files on startup, based on whether the device claimed that the SD\nCard (or equivalent storage partition) was mounted. If the SD Card was mounted,\nor if a large internal storage partition was available (such as on Nexus\ndevices,) then the persistent files would be stored in the root of that space.\nThis meant that all Cordova apps could see all of the files available on the\ncard.\n\nIf the SD card was not available, then previous versions would store data under\n`/data/data/<packageId>`, which isolates apps from each other, but may still\ncause data to be shared between users.\n\nIt is now possible to choose whether to store files in the internal file\nstorage location, or using the previous logic, with a preference in your\napplication's `config.xml` file. To do this, add one of these two lines to\n`config.xml`:\n\n    <preference name=\"AndroidPersistentFileLocation\" value=\"Internal\" />\n\n    <preference name=\"AndroidPersistentFileLocation\" value=\"Compatibility\" />\n\nWithout this line, the File plugin will use `Compatibility` as the default. If\na preference tag is present, and is not one of these values, the application\nwill not start.\n\nIf your application has previously been shipped to users, using an older (pre-\n1.0) version of this plugin, and has stored files in the persistent filesystem,\nthen you should set the preference to `Compatibility`. Switching the location to\n\"Internal\" would mean that existing users who upgrade their application may be\nunable to access their previously-stored files, depending on their device.\n\nIf your application is new, or has never previously stored files in the\npersistent filesystem, then the `Internal` setting is generally recommended.\n\n\n## iOS Quirks\n\n- `cordova.file.applicationStorageDirectory` is read-only; attempting to store \n  files within the root directory will fail. Use one of the other `cordova.file.*`\n  properties defined for iOS (only `applicationDirectory` and `applicationStorageDirectory` are\n  read-only).\n- `FileReader.readAsText(blob, encoding)`\n  - The `encoding` parameter is not supported, and UTF-8 encoding is always in effect.\n\n### iOS Persistent storage location\n\nThere are two valid locations to store persistent files on an iOS device: the\nDocuments directory and the Library directory. Previous versions of the plugin\nonly ever stored persistent files in the Documents directory. This had the\nside-effect of making all of an application's files visible in iTunes, which\nwas often unintended, especially for applications which handle lots of small\nfiles, rather than producing complete documents for export, which is the\nintended purpose of the directory.\n\nIt is now possible to choose whether to store files in the documents or library\ndirectory, with a preference in your application's `config.xml` file. To do this,\nadd one of these two lines to `config.xml`:\n\n    <preference name=\"iosPersistentFileLocation\" value=\"Library\" />\n\n    <preference name=\"iosPersistentFileLocation\" value=\"Compatibility\" />\n\nWithout this line, the File plugin will use `Compatibility` as the default. If\na preference tag is present, and is not one of these values, the application\nwill not start.\n\nIf your application has previously been shipped to users, using an older (pre-\n1.0) version of this plugin, and has stored files in the persistent filesystem,\nthen you should set the preference to `Compatibility`. Switching the location to\n`Library` would mean that existing users who upgrade their application would be\nunable to access their previously-stored files.\n\nIf your application is new, or has never previously stored files in the\npersistent filesystem, then the `Library` setting is generally recommended.\n\n## Firefox OS Quirks\n\nThe File System API is not natively supported by Firefox OS and is implemented\nas a shim on top of indexedDB. \n \n* Does not fail when removing non-empty directories\n* Does not support metadata for directories\n* Methods `copyTo` and `moveTo` do not support directories\n\nThe following data paths are supported:\n* `applicationDirectory` - Uses `xhr` to get local files that are packaged with the app.\n* `dataDirectory` - For persistent app-specific data files.\n* `cacheDirectory` - Cached files that should survive app restarts (Apps should not rely\non the OS to delete files in here).\n\n## Upgrading Notes\n\nIn v1.0.0 of this plugin, the `FileEntry` and `DirectoryEntry` structures have changed,\nto be more in line with the published specification.\n\nPrevious (pre-1.0.0) versions of the plugin stored the device-absolute-file-location\nin the `fullPath` property of `Entry` objects. These paths would typically look like\n\n    /var/mobile/Applications/<application UUID>/Documents/path/to/file  (iOS)\n    /storage/emulated/0/path/to/file                                    (Android)\n\nThese paths were also returned by the `toURL()` method of the `Entry` objects.\n\nWith v1.0.0, the `fullPath` attribute is the path to the file, _relative to the root of\nthe HTML filesystem_. So, the above paths would now both be represented by a `FileEntry`\nobject with a `fullPath` of\n\n    /path/to/file\n\nIf your application works with device-absolute-paths, and you previously retrieved those\npaths through the `fullPath` property of `Entry` objects, then you should update your code\nto use `entry.toURL()` instead.\n\nFor backwards compatibility, the `resolveLocalFileSystemURL()` method will accept a\ndevice-absolute-path, and will return an `Entry` object corresponding to it, as long as that\nfile exists within either the `TEMPORARY` or `PERSISTENT` filesystems.\n\nThis has particularly been an issue with the File-Transfer plugin, which previously used\ndevice-absolute-paths (and can still accept them). It has been updated to work correctly\nwith FileSystem URLs, so replacing `entry.fullPath` with `entry.toURL()` should resolve any\nissues getting that plugin to work with files on the device.\n\nIn v1.1.0 the return value of `toURL()` was changed (see [CB-6394] (https://issues.apache.org/jira/browse/CB-6394))\nto return an absolute 'file://' URL. wherever possible. To ensure a 'cdvfile:'-URL you can use `toInternalURL()` now.\nThis method will now return filesystem URLs of the form\n\n    cdvfile://localhost/persistent/path/to/file\n\nwhich can be used to identify the file uniquely.\n\n## List of Error Codes and Meanings\nWhen an error is thrown, one of the following codes will be used. \n\n| Code | Constant                      |\n|-----:|:------------------------------|\n|    1 | `NOT_FOUND_ERR`               |\n|    2 | `SECURITY_ERR`                |\n|    3 | `ABORT_ERR`                   |\n|    4 | `NOT_READABLE_ERR`            |\n|    5 | `ENCODING_ERR`                |\n|    6 | `NO_MODIFICATION_ALLOWED_ERR` |\n|    7 | `INVALID_STATE_ERR`           |\n|    8 | `SYNTAX_ERR`                  |\n|    9 | `INVALID_MODIFICATION_ERR`    |\n|   10 | `QUOTA_EXCEEDED_ERR`          |\n|   11 | `TYPE_MISMATCH_ERR`           |\n|   12 | `PATH_EXISTS_ERR`             |\n\n## Configuring the Plugin (Optional)\n\nThe set of available filesystems can be configured per-platform. Both iOS and\nAndroid recognize a <preference> tag in `config.xml` which names the\nfilesystems to be installed. By default, all file-system roots are enabled.\n\n    <preference name=\"iosExtraFilesystems\" value=\"library,library-nosync,documents,documents-nosync,cache,bundle,root\" />\n    <preference name=\"AndroidExtraFilesystems\" value=\"files,files-external,documents,sdcard,cache,cache-external,root\" />\n\n### Android\n\n* `files`: The application's internal file storage directory\n* `files-external`: The application's external file storage directory\n* `sdcard`: The global external file storage directory (this is the root of the SD card, if one is installed). You must have the `android.permission.WRITE_EXTERNAL_STORAGE` permission to use this.\n* `cache`: The application's internal cache directory\n* `cache-external`: The application's external cache directory\n* `root`: The entire device filesystem\n\nAndroid also supports a special filesystem named \"documents\", which represents a \"/Documents/\" subdirectory within the \"files\" filesystem.\n\n### iOS\n\n* `library`: The application's Library directory\n* `documents`: The application's Documents directory\n* `cache`: The application's Cache directory\n* `bundle`: The application's bundle; the location of the app itself on disk (read-only)\n* `root`: The entire device filesystem\n\nBy default, the library and documents directories can be synced to iCloud. You can also request two additional filesystems, `library-nosync` and `documents-nosync`, which represent a special non-synced directory within the `/Library` or `/Documents` filesystem.\n"
}